﻿/********************************************************************************
** @ Date:2025/04/23
** @ Author: Gaojia
** @ Description: 公共头文件
** @ Version:1.0.0
** @ Fun:
********************************************************************************/
#ifndef Global_H
#define Global_H
#include <QMessageBox>
#include <QString>
#include <QWidget>
#include <QMap>
#include <QSet>
#include <windows.h>
#define A2T QString::fromLocal8Bit
#define FL  __FILE__+(","+QString::number(__LINE__)) 

#define _Q(x) (x).toLocal8Bit().data()                  //QString中含有中文转char * 需要使用toLocal8Bit().data() 
#define _QStr2CharStr(x) x.toStdString().c_str()        //将QString 转化成 char* 字符串
#define _QSClearPoint(x)  QString::number(x.toDouble(), 'f', 0).toStdString().c_str()        //将QString 转化成 char* 字符串 同时去除对应的小数位
#define _QNumStr2UInt(x) (unsigned int)x.toDouble()     //将QString 数值转化成unsigned int
#define _QNumStr2Int(x) (int)x.toDouble()               //将QString 数值转化

/**
* @ Author: Gaojia
* @ Description: 全局对象
*/
class CBaseNode;
class CBaseScene;
class CBaseCarouse;
class CMeasurePoint;
class CDeviceManager;
class UToolBarManager;
class CAlarmPoint;
class UNodeManager;

extern CBaseNode *g_pRoot;               //设备管理树根节点
extern CBaseScene* g_pRootScene;         //场景管理树根节点
extern CBaseCarouse* g_pRootCarouse;      //轮播管理树根节点
extern CDeviceManager* g_pDeviceManager;  // 设备管理器
extern UToolBarManager *g_pToolBarMang;  //工具栏管理对象
extern QSet<QString> g_allIds;
extern UNodeManager* g_pNodeManager;



struct SDeviceWidget
{
	QString sDllNameCh;  //驱动中文名称
	QString sDllName;
	QString sTypeName;
	int nDeviceType;
	QVector<QWidget *>vecWidget;
	SDeviceWidget()
	{
		sDllNameCh = "";
		sDllName = "";
		sTypeName = "";
		nDeviceType = 0;
	}
};
extern QMap<QString, QString>g_mapDllName;  //驱动和驱动名称
extern QMap<QString, QString>g_mapNameDll;  //驱动和驱动名称
extern  QMap<QString,QMap<int, SDeviceWidget>>g_mapCardWidget;  //所有设备缩略图数组
/**
* @ Author: Gaojia
* @ Description: 全局函数
*/
QString generateUniqueId(const QString& prefix);         // 生成唯一 ID
extern CBaseNode *findNodeByGuid(const QString& sGuid);  //使用guid查找设备
extern QVector<CAlarmPoint*>getTechAlarmPoint(QString sArea = "*");
extern QVector<CAlarmPoint*>getFaultAlarmPoint(QString sArea = "*");
extern bool showMessageBox(QWidget* parent, const QString& title, const QString& message, int nType = 0, bool withCancel = false);
extern QString showGetText(QWidget* parent,const QString& title,const QString& label,const QString& defaultText = "");
extern QString getCardQss(); //获取全局卡片样式
extern void getChildAlarmPoint(QVector<CAlarmPoint*>&vecPoint,CBaseNode* pChild,int nType, QString sArea = "*");
extern bool setNativeTitleBarColor(HWND hwnd, COLORREF color);
class Global
{
public:
	Global();
	~Global();
};

#endif